package org.spiderflow.common.enums;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 流程通知方式
 *
 * @author BillDowney
 * @date 2020年4月3日 下午3:26:18
 */
public enum FlowNoticeWay {
    /**
     *
     */
    EMAIL("邮件通知");

    FlowNoticeWay(String title) {
        this.title = title;
    }

    private static final Logger LOGGER = LoggerFactory.getLogger(FlowNoticeWay.class);
    private final String title;

    @Override
    public String toString() {
        return this.name() + ":" + this.title;
    }

    public static Map<String, String> getMap() {
        Map<String, String> map = new LinkedHashMap<>();
        for (FlowNoticeWay type : FlowNoticeWay.values()) {
            map.put(type.name(), type.toString());
        }
        return map;
    }

    public static FlowNoticeWay valueOf(String name, FlowNoticeWay defaultValue) {
        try {
            return FlowNoticeWay.valueOf(name);
        } catch (IllegalArgumentException e) {
            LOGGER.error("枚举转换失败 name->{}", name, e);
            return defaultValue;
        }
    }

}
